<template>
	<view class="page">
		<view class="flex benben-position-layout flex flex-wrap align-center QuestionBank_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub QuestionBank_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  QuestionBank_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<text class='QuestionBank_fd0_0_c1'>资料下载</text>
				<view class='flex flex-wrap align-center QuestionBank_fd0_0_c2'>
				</view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout QuestionBank_flex_1">
			<template v-for='(item,key0) in classList'>
				<view class='flex flex-wrap align-center QuestionBank_fd1_0' :key='key0'>
					<!-- <image class='QuestionBank_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"21.png"'></image> -->
					<text class='flex-sub QuestionBank_fd1_0_c1' v-if="type == 1">{{item.name}}</text>
					<image class="download_icon" src="https://app.ezsdcsm.com/images/85.png" mode="" @tap="getDownload(item.file)">
					</image>
				</view>
			</template>
			<benben-empty v-if="classList.length == 0">
				<view class='flex flex-direction flex-wrap align-center wrongQuestion_fd3_1'>
					<image class='wrongQuestion_fd3_1_c0' mode="widthFix" :src='STATIC_URL+"78.png"'></image>
					<text class='wrongQuestion_fd3_1_c1'>暂无资料~</text>

				</view>
			</benben-empty>
		</view>
		<!---flex布局flex布局结束-->

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				"city": "",
				"type": "1",
				"classList": []
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			this.city = uni.getStorageSync('city');
			this.city = '武汉';
			this.getClassList();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.getClassList()
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取题库列表
			async getClassList() {
				//请求方法
				//数据验证
				let classListData = await this.$api.post(global.apiUrls.post634405a78b067, {
					city: this.city
				});
				uni.stopPullDownRefresh();
				if (classListData.data.code != 1) {
					this.$message.info(classListData.data.msg);
					return
				}
				let classListinfo = classListData.data;
				this.classList = classListinfo.data
				console.log(this.classList);
			},
			// 下载
			getDownload(file) {
				uni.showLoading({
					title: '下载中...'
				})
				uni.downloadFile({
					url: file, // 文件下载路径
					success: (res) => {
						uni.hideLoading();
						console.log(res);
						if (res.statusCode === 200) {
							//保存成功并打开文件
							uni.openDocument({
								filePath: res.tempFilePath,
								success: (res) => console.log('成功打开文件')
							})
						}
					},
					fail(err) {
						uni.hideLoading();
						this.$message.info('下载失败');
					}
				});
			}
		}
	};
</script>
<style lang="scss" scoped>
	.QuestionBank_fd1_0 {
		background: #fff;
		background-size: 100% !important;
		// height: 100rpx;
		padding: 24rpx 32rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.QuestionBank_fd1_0_c0 {
		width: 88rpx;
		height: 88rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
	}

	.QuestionBank_fd1_0_c1 {
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.download_icon {
		width: 36rpx;
		height: 36rpx;
	}

	.QuestionBank_fd1_0_c2 {
		font-size: 26rpx;
		font-weight: 500;
		color: #333;
	}

	.QuestionBank_flex_1 {
		margin: 32rpx 32rpx 0rpx 32rpx;
	}

	.QuestionBank_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.QuestionBank_fd0_0_c0_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
		line-height: 36rpx;
	}

	.QuestionBank_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 50rpx;
	}

	.QuestionBank_fd0_0_c2 {
		width: 36rpx;
		height: 36rpx;
	}

	.QuestionBank_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(246, 247, 249, 1);
		background-size: 100% auto !important;
	}
</style>
